using System;
using BitMango; 
using UnityEngine;

public class UncleBillContext : MonoBehaviour
{
	public PlatformContext.StoreType storeType
	{
		get
		{
			return Context.BMPlatform.storeType;
		}
	}

	public ShopItem GetShopItemByID(string id)
	{
		foreach (ShopItem shopItem in this.shopItems)
		{
			if (shopItem.id == id)
			{
				return shopItem;
			}
		}
		return null;
	}

	public ShopItem GetShopItemByPriceID(string id)
	{
		foreach (ShopItem shopItem in this.shopItems)
		{
			if (shopItem.GetPriceID() == id)
			{
				return shopItem;
			}
		}
		return null;
	}

	public InventoryItem GetInventoryItemByID(string id)
	{
		foreach (InventoryItem inventoryItem in this.inventoryItems)
		{
			if (inventoryItem.id == id)
			{
				return inventoryItem;
			}
		}
		return null;
	}

	private void Awake()
	{
		Context.UncleBill = this;
		WalletInstance walletInstance = new WalletInstance(this);
		Wallet.current = walletInstance;
		walletInstance.Load();
		//UncleBill.PrepareToOpen(null);
	}

	private void OnApplicationPause(bool pause)
	{
		if (pause && Wallet.current != null && Wallet.current.loaded)
		{
			Wallet.Save();
		}
	}

	private void OnApplicationQuit()
	{
		if (Wallet.current != null && Wallet.current.loaded)
		{
			Wallet.Save();
		}
	}

	public InventoryItem[] inventoryItems;

	public ShopItem[] shopItems;
}
